diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-09-17 13:55:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-09-17 14:12:08 +0100 |
commit | 3647626309ef89bf90d8b6a6539d41d8deb6b482 (patch) | |
tree | f0857159687aaa908c308f441786b593ff0fd649 /sw | |
parent | ddc280920282ff3e2801e9a79f9dfa8a6c6f5699 (diff) |
Give drawing objects unique names by default
when created through the UI, similar to how
frames and graphics get names.
This way they appear in the navigator by default
Change-Id: I5ec92221583494a0908948d6d0c0815980cb7050
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/comcore.hrc | 1 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 1 | ||||
-rw-r--r-- | sw/inc/fesh.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/doc/doclay.cxx | 43 | ||||
-rw-r--r-- | sw/source/core/frmedt/feflyole.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/frmedt/feshview.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/app/app.src | 5 |
7 files changed, 49 insertions, 10 deletions
diff --git a/sw/inc/comcore.hrc b/sw/inc/comcore.hrc index 5b26debe70f0..f56dd0829da4 100644 --- a/sw/inc/comcore.hrc +++ b/sw/inc/comcore.hrc @@ -39,6 +39,7 @@ #define STR_MULT_INTERACT_SPELL_WARN (RC_COMCORE_BEGIN + 14) #define STR_SPELL_TITLE (RC_COMCORE_BEGIN + 15) #define STR_HYPH_TITLE (RC_COMCORE_BEGIN + 16) +#define STR_SHAPE_DEFNAME (RC_COMCORE_BEGIN + 17) #define STR_REDLINE_INSERT (RC_COMCORE_BEGIN + 19) #define STR_REDLINE_DELETE (RC_COMCORE_BEGIN + 20) diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 3b4d99a3a148..1bbca5b19d23 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -729,6 +729,7 @@ public: OUString GetUniqueGrfName() const; OUString GetUniqueOLEName() const; OUString GetUniqueFrameName() const; + OUString GetUniqueShapeName() const; std::set<SwRootFrm*> GetAllLayouts(); diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 2cda774138d0..a219ac1f6997 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -463,6 +463,7 @@ public: OUString GetUniqueGrfName() const; OUString GetUniqueOLEName() const; OUString GetUniqueFrameName() const; + OUString GetUniqueShapeName() const; /// Jump to named Fly (graphic/OLE). bool GotoFly( const OUString& rName, FlyCntType eType = FLYCNTTYPE_ALL, diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index dc42c5cf3ce2..93a86288e4c5 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1263,7 +1263,7 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel( return pNewFormat; } -static OUString lcl_GetUniqueFlyName( const SwDoc* pDoc, sal_uInt16 nDefStrId ) +static OUString lcl_GetUniqueFlyName(const SwDoc* pDoc, sal_uInt16 nDefStrId, RES_FMT eType) { if( pDoc->IsInMailMerge()) { @@ -1284,11 +1284,23 @@ static OUString lcl_GetUniqueFlyName( const SwDoc* pDoc, sal_uInt16 nDefStrId ) for( SwFrameFormats::size_type n = 0; n < rFormats.size(); ++n ) { const SwFrameFormat* pFlyFormat = rFormats[ n ]; - if( RES_FLYFRMFMT == pFlyFormat->Which() && - pFlyFormat->GetName().startsWith( aName ) ) + if (eType != pFlyFormat->Which()) + continue; + OUString sName; + if (eType == RES_DRAWFRMFMT) + { + const SdrObject *pObj = pFlyFormat->FindSdrObject(); + if (pObj) + sName = pObj->GetName(); + } + else + { + sName = pFlyFormat->GetName(); + } + if (sName.startsWith(aName)) { // Only get and set the Flag - const sal_Int32 nNum = pFlyFormat->GetName().copy( nNmLen ).toInt32()-1; + const sal_Int32 nNum = sName.copy(nNmLen).toInt32()-1; if( nNum >= 0 && static_cast<SwFrameFormats::size_type>(nNum) < rFormats.size() ) aSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 )); } @@ -1314,17 +1326,22 @@ static OUString lcl_GetUniqueFlyName( const SwDoc* pDoc, sal_uInt16 nDefStrId ) OUString SwDoc::GetUniqueGrfName() const { - return lcl_GetUniqueFlyName( this, STR_GRAPHIC_DEFNAME ); + return lcl_GetUniqueFlyName(this, STR_GRAPHIC_DEFNAME, RES_FLYFRMFMT); } OUString SwDoc::GetUniqueOLEName() const { - return lcl_GetUniqueFlyName( this, STR_OBJECT_DEFNAME ); + return lcl_GetUniqueFlyName(this, STR_OBJECT_DEFNAME, RES_FLYFRMFMT); } OUString SwDoc::GetUniqueFrameName() const { - return lcl_GetUniqueFlyName( this, STR_FRAME_DEFNAME ); + return lcl_GetUniqueFlyName(this, STR_FRAME_DEFNAME, RES_FLYFRMFMT); +} + +OUString SwDoc::GetUniqueShapeName() const +{ + return lcl_GetUniqueFlyName(this, STR_SHAPE_DEFNAME, RES_DRAWFRMFMT); } const SwFlyFrameFormat* SwDoc::FindFlyByName( const OUString& rName, sal_Int8 nNdTyp ) const @@ -1362,12 +1379,18 @@ void SwDoc::SetFlyName( SwFlyFrameFormat& rFormat, const OUString& rName ) sal_uInt16 nTyp = STR_FRAME_DEFNAME; const SwNodeIndex* pIdx = rFormat.GetContent().GetContentIdx(); if( pIdx && pIdx->GetNode().GetNodes().IsDocNodes() ) + { switch( GetNodes()[ pIdx->GetIndex() + 1 ]->GetNodeType() ) { - case ND_GRFNODE: nTyp = STR_GRAPHIC_DEFNAME; break; - case ND_OLENODE: nTyp = STR_OBJECT_DEFNAME; break; + case ND_GRFNODE: + nTyp = STR_GRAPHIC_DEFNAME; + break; + case ND_OLENODE: + nTyp = STR_OBJECT_DEFNAME; + break; } - sName = lcl_GetUniqueFlyName( this, nTyp ); + } + sName = lcl_GetUniqueFlyName(this, nTyp, RES_FLYFRMFMT); } rFormat.SetName( sName, true ); getIDocumentState().SetModified(); diff --git a/sw/source/core/frmedt/feflyole.cxx b/sw/source/core/frmedt/feflyole.cxx index 2faaab04d0a7..ca5b36f52236 100644 --- a/sw/source/core/frmedt/feflyole.cxx +++ b/sw/source/core/frmedt/feflyole.cxx @@ -92,6 +92,11 @@ OUString SwFEShell::GetUniqueFrameName() const return GetDoc()->GetUniqueFrameName(); } +OUString SwFEShell::GetUniqueShapeName() const +{ + return GetDoc()->GetUniqueShapeName(); +} + bool SwFEShell::FinishOLEObj() // Server is terminated { SfxInPlaceClient* pIPClient = GetSfxViewShell()->GetIPClient(); diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 9000746d0819..473f686cf16d 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -1858,6 +1858,9 @@ bool SwFEShell::ImpEndCreate() pAnch = pTmp; } + if (rSdrObj.GetName().isEmpty()) + rSdrObj.SetName(GetUniqueShapeName()); + pContact->ConnectToLayout(); // mark object at frame the object is inserted at. diff --git a/sw/source/ui/app/app.src b/sw/source/ui/app/app.src index c4fee49aad04..b60a7b0a32c4 100644 --- a/sw/source/ui/app/app.src +++ b/sw/source/ui/app/app.src @@ -396,6 +396,11 @@ String STR_FRAME_DEFNAME Text [ en-US ] = "Frame" ; }; +String STR_SHAPE_DEFNAME +{ + Text [ en-US ] = "Shape" ; +}; + String STR_REGION_DEFNAME { Text [ en-US ] = "Section" ; |