kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0065-Related-fdo-81641-create-new-styles-with-an-initial-.patch

f085be
From 30ef30970073b969430011da25e9412ffc217e8b Mon Sep 17 00:00:00 2001
f085be
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f085be
Date: Thu, 24 Jul 2014 11:55:46 +0100
f085be
Subject: [PATCH 065/137] Related: fdo#81641 create new styles with an initial
f085be
 name
f085be
MIME-Version: 1.0
f085be
Content-Type: text/plain; charset=UTF-8
f085be
Content-Transfer-Encoding: 8bit
f085be
f085be
instead of creating with a blank name and changing it later
f085be
f085be
this way undo of a style creation is initialized with its name and so create a
f085be
style followed by deleting a style and undoing all those steps doesn't crash
f085be
f085be
(cherry picked from commit e904562af54545684b32d2042ded6bdb9459edca)
f085be
f085be
Conflicts:
f085be
	include/sfx2/styledlg.hxx
f085be
	sw/source/uibase/app/docst.cxx
f085be
f085be
Change-Id: Ida7a34410d5d7b05edcb86950aabb3c672b82c8f
f085be
f085be
style category listbox depends on being unsorted
f085be
f085be
regression from
f085be
f085be
commit 6ecfbf153a7c11c63d208630ac6a27064058099d
f085be
Author: Caolán McNamara <caolanm@redhat.com>
f085be
Date:   Wed Mar 13 15:10:25 2013 +0000
f085be
f085be
    drop unused resources and toggle label to activate replacement widget
f085be
f085be
Change-Id: I65ca8ec58ed984120f3c2e7ba68507cbf8acf089
f085be
(cherry picked from commit 11fab6b705638359b2ca0e3e85590aa7cc70a03a)
f085be
f085be
Related: fdo#81641 exclude 'all styles' category from organizer page
f085be
f085be
it doesn't make sense to be able to assign a style to
f085be
'all styles'
f085be
f085be
Change-Id: I632c62f293b553e436ceb8da0baf2bb39941fd39
f085be
(cherry picked from commit 2223ff6cb99df097a357674801835c7a260b551d)
f085be
f085be
Resolves: fdo#81641 the new style shouldn't be a conditional style
f085be
f085be
regression from
f085be
f085be
commit 715d79bcc59d68c77dc84a1038998dd873df92e9
f085be
Author: Cédric Bosdonnat <cedric.bosdonnat@free.fr>
f085be
Date:   Fri Nov 30 11:51:46 2012 +0100
f085be
f085be
    Styles & Formatting: added SFXSTYLEBIT_ALL_VISIBLE and show hidden styles
f085be
f085be
commit 2fd9c2bf9af0c50dae3af3dbe5e22965ccdb4ae7
f085be
Author: Cédric Bosdonnat <cedric.bosdonnat@free.fr>
f085be
Date:   Sun Nov 25 15:24:42 2012 +0100
f085be
f085be
    Allow to hide styles in the "Styles & Formating" dialog
f085be
f085be
    In its current state, the feature only hides the styles. Things to sort
f085be
    out are:
f085be
     + Add some automatic filter to show hidden styles
f085be
     + Make the visibility persist in the file format
f085be
f085be
(cherry picked from commit 1af0e46102350114dd5e854b7692c640dae2727f)
f085be
f085be
Conflicts:
f085be
	sw/source/uibase/app/docst.cxx
f085be
f085be
Change-Id: I7244d424765db0d5ed3aeaf380a8e1af56aa7eaf
f085be
Reviewed-on: https://gerrit.libreoffice.org/10503
f085be
Reviewed-by: Michael Stahl <mstahl@redhat.com>
f085be
Tested-by: Michael Stahl <mstahl@redhat.com>
f085be
---
f085be
 include/sfx2/styledlg.hxx       |  3 +++
f085be
 sfx2/source/dialog/mgetempl.cxx | 16 +++++-----------
f085be
 sfx2/source/dialog/styledlg.cxx | 14 ++++++++++++++
f085be
 sw/source/ui/app/docst.cxx      |  6 +++++-
f085be
 4 files changed, 27 insertions(+), 12 deletions(-)
f085be
f085be
diff --git a/include/sfx2/styledlg.hxx b/include/sfx2/styledlg.hxx
f085be
index b53e8cd..8888473 100644
f085be
--- a/include/sfx2/styledlg.hxx
f085be
+++ b/include/sfx2/styledlg.hxx
f085be
@@ -25,6 +25,7 @@
f085be
 #include <sfx2/tabdlg.hxx>
f085be
 
f085be
 class SfxStyleSheetBase;
f085be
+class SfxStyleSheetBasePool;
f085be
 
f085be
 class SFX2_DLLPUBLIC SfxStyleDialog: public SfxTabDialog
f085be
 {
f085be
@@ -45,6 +46,8 @@ public:
f085be
     const SfxStyleSheetBase&    GetStyleSheet() const { return *pStyle; }
f085be
 
f085be
     virtual short               Ok();
f085be
+
f085be
+    static OUString GenerateUnusedName(SfxStyleSheetBasePool &rPool);
f085be
 };
f085be
 
f085be
 #endif
f085be
diff --git a/sfx2/source/dialog/mgetempl.cxx b/sfx2/source/dialog/mgetempl.cxx
f085be
index cedbdc1..97dcf81 100644
f085be
--- a/sfx2/source/dialog/mgetempl.cxx
f085be
+++ b/sfx2/source/dialog/mgetempl.cxx
f085be
@@ -67,7 +67,9 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS
f085be
     m_pBaseLb->setMaxWidthChars(nMaxWidth);
f085be
     get(m_pFilterFt, "categoryft");
f085be
     get(m_pFilterLb, "category");
f085be
-    m_pFilterLb->SetStyle(m_pFilterLb->GetStyle() | WB_SORT);
f085be
+    //note that the code depends on categories not being lexically
f085be
+    //sorted, so if its changed to sorted, the code needs to
f085be
+    //be adapted to be position unaware
f085be
     m_pFilterLb->setMaxWidthChars(nMaxWidth);
f085be
     get(m_pDescFt, "desc");
f085be
 
f085be
@@ -94,16 +96,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS
f085be
     if ( pStyle->GetName().isEmpty() && pPool )
f085be
     {
f085be
         // NullString as Name -> generate Name
f085be
-        OUString aNoName( SfxResId(STR_NONAME).toString() );
f085be
-        sal_uInt16 nNo = 1;
f085be
-        OUString aNo( aNoName );
f085be
-        aNoName += OUString::number( nNo );
f085be
-        while ( pPool->Find( aNoName ) )
f085be
-        {
f085be
-            ++nNo;
f085be
-            aNoName = aNo;
f085be
-            aNoName += OUString::number( nNo );
f085be
-        }
f085be
+        OUString aNoName(SfxStyleDialog::GenerateUnusedName(*pPool));
f085be
         pStyle->SetName( aNoName );
f085be
         aName = aNoName;
f085be
         aFollow = pStyle->GetFollow();
f085be
@@ -193,6 +186,7 @@ SfxManageStyleSheetPage::SfxManageStyleSheetPage(Window* pParent, const SfxItemS
f085be
 
f085be
             if ( pTupel->nFlags != SFXSTYLEBIT_AUTO     &&
f085be
                  pTupel->nFlags != SFXSTYLEBIT_USED     &&
f085be
+                 pTupel->nFlags != SFXSTYLEBIT_ALL_VISIBLE &&
f085be
                  pTupel->nFlags != SFXSTYLEBIT_ALL )
f085be
             {
f085be
                 m_pFilterLb->InsertEntry( pTupel->aName, nIdx );
f085be
diff --git a/sfx2/source/dialog/styledlg.cxx b/sfx2/source/dialog/styledlg.cxx
f085be
index 6b4051d..d4945a8 100644
f085be
--- a/sfx2/source/dialog/styledlg.cxx
f085be
+++ b/sfx2/source/dialog/styledlg.cxx
f085be
@@ -147,5 +147,19 @@ IMPL_LINK( SfxStyleDialog, CancelHdl, Button *, pButton )
f085be
     return 0;
f085be
 }
f085be
 
f085be
+OUString SfxStyleDialog::GenerateUnusedName(SfxStyleSheetBasePool &rPool)
f085be
+{
f085be
+    OUString aNoName(SfxResId(STR_NONAME).toString());
f085be
+    sal_uInt16 nNo = 1;
f085be
+    OUString aNo(aNoName);
f085be
+    aNoName += OUString::number(nNo);
f085be
+    while (rPool.Find(aNoName))
f085be
+    {
f085be
+        ++nNo;
f085be
+        aNoName = aNo;
f085be
+        aNoName += OUString::number(nNo);
f085be
+    }
f085be
+    return aNoName;
f085be
+}
f085be
 
f085be
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
f085be
diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx
f085be
index 4c05499..1f12a30 100644
f085be
--- a/sw/source/ui/app/docst.cxx
f085be
+++ b/sw/source/ui/app/docst.cxx
f085be
@@ -25,6 +25,7 @@
f085be
 
f085be
 #include <hintids.hxx>
f085be
 #include <sfx2/app.hxx>
f085be
+#include <sfx2/styledlg.hxx>
f085be
 #include <svl/whiter.hxx>
f085be
 #include <sfx2/templdlg.hxx>
f085be
 #include <sfx2/tplpitem.hxx>
f085be
@@ -285,6 +286,9 @@ void SwDocShell::ExecStyleSheet( SfxRequest& rReq )
f085be
                 sal_False, &pItem ))
f085be
                 sParent = ((const SfxStringItem*)pItem)->GetValue();
f085be
 
f085be
+            if (sName.isEmpty() && mxBasePool.get())
f085be
+                sName = SfxStyleDialog::GenerateUnusedName(*mxBasePool);
f085be
+
f085be
             nRet = Edit( sName, sParent, nFamily, nMask, sal_True, OString(), 0, rReq.IsAPI() );
f085be
         }
f085be
         break;
f085be
@@ -615,7 +619,7 @@ sal_uInt16 SwDocShell::Edit(
f085be
 
f085be
     if( bNew )
f085be
     {
f085be
-        if( SFXSTYLEBIT_ALL != nMask && SFXSTYLEBIT_USED != nMask )
f085be
+        if (SFXSTYLEBIT_ALL != nMask && SFXSTYLEBIT_ALL_VISIBLE != nMask && SFXSTYLEBIT_USED != nMask)
f085be
             nMask |= SFXSTYLEBIT_USERDEF;
f085be
         else
f085be
             nMask = SFXSTYLEBIT_USERDEF;
f085be
-- 
f085be
1.9.3
f085be