LibreOffice Module sw (master) 1
sdrhhcwrap.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <svx/svdotext.hxx>
21#include <svx/svdpagv.hxx>
22#include <sfx2/printer.hxx>
23#include <svx/svdview.hxx>
24#include <osl/diagnose.h>
25#include <drawdoc.hxx>
26#include "sdrhhcwrap.hxx"
27#include <docsh.hxx>
28#include <wrtsh.hxx>
29#include <view.hxx>
30#include <dcontact.hxx>
31#include <doc.hxx>
34#include <edtwin.hxx>
35
36using namespace ::com::sun::star;
37
39 LanguageType nSourceLanguage, LanguageType nTargetLanguage,
40 const vcl::Font* pTargetFnt,
41 sal_Int32 nConvOptions,
42 bool bInteractive ) :
43 SdrOutliner(pVw->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->
44 GetDrawOutliner().GetEmptyItemSet().GetPool(),
46 m_pView( pVw ),
47 m_pTextObj( nullptr ),
48 m_nOptions( nConvOptions ),
49 m_nDocIndex( 0 ),
50 m_nSourceLang( nSourceLanguage ),
51 m_nTargetLang( nTargetLanguage ),
52 m_pTargetFont( pTargetFnt ),
53 m_bIsInteractive( bInteractive )
54{
55 SetRefDevice( m_pView->GetDocShell()->GetDoc()->getIDocumentDeviceAccess().getPrinter( false ) );
56
57 MapMode aMapMode (MapUnit::MapTwip);
58 SetRefMapMode(aMapMode);
59
60 Size aSize( 1, 1 );
61 SetPaperSize( aSize );
62
63 m_pOutlView.reset( new OutlinerView( this, &(m_pView->GetEditWin()) ) );
64 m_pOutlView->GetOutliner()->SetRefDevice(m_pView->GetWrtShell().getIDocumentDeviceAccess().getPrinter( false ));
65
66 // Hack: all SdrTextObj attributes should be transferred to EditEngine
67 m_pOutlView->SetBackgroundColor( COL_WHITE );
68
69 InsertView( m_pOutlView.get() );
70 Point aPoint( 0, 0 );
71 tools::Rectangle aRect( aPoint, aSize );
72 m_pOutlView->SetOutputArea( aRect );
73// SetText( NULL );
74 ClearModifyFlag();
75}
76
78{
79 if (m_pTextObj)
80 {
81 SdrView *pSdrView = m_pView->GetWrtShell().GetDrawView();
82 OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
83 pSdrView->SdrEndTextEdit( true );
84 SetUpdateLayout(false);
85 m_pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
86 }
87 RemoveView( m_pOutlView.get() );
88 m_pOutlView.reset();
89}
90
92{
94}
95
97{
98 bool bNextDoc = false;
99
100 if ( m_pTextObj )
101 {
102 SdrView *pSdrView = m_pView->GetWrtShell().GetDrawView();
103 OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
104 pSdrView->SdrEndTextEdit( true );
105 SetUpdateLayout(false);
106 m_pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1, 1) ) );
107 SetPaperSize( Size(1, 1) );
108 Clear();
109 m_pTextObj = nullptr;
110 }
111
112 const auto n = m_nDocIndex;
113
114 std::list<SdrTextObj*> aTextObjs;
116 for (auto const& textObj : aTextObjs)
117 {
118 m_pTextObj = textObj;
119 if (textObj)
120 {
121 OutlinerParaObject* pParaObj = textObj->GetOutlinerParaObject();
122 if ( pParaObj )
123 {
124 SetPaperSize( textObj->GetLogicRect().GetSize() );
125 SetText( *pParaObj );
126
127 ClearModifyFlag();
128
134 SetUpdateLayout(true);
135 if (HasConvertibleTextPortion( m_nSourceLang ))
136 {
137 SdrView *pSdrView = m_pView->GetWrtShell().GetDrawView();
138 OSL_ENSURE( pSdrView, "SdrHHCWrapper without DrawView?" );
139 SdrPageView* pPV = pSdrView->GetSdrPageView();
140 m_nDocIndex = n;
141 bNextDoc = true;
142 m_pOutlView->SetOutputArea( tools::Rectangle( Point(), Size(1,1)));
144 SetUpdateLayout(true);
146
147 pSdrView->SdrBeginTextEdit(m_pTextObj, pPV, &m_pView->GetEditWin(), false, this, m_pOutlView.get(), true, true);
148 }
149 else
150 SetUpdateLayout(false);
151 }
152
153 if ( !bNextDoc )
154 m_pTextObj = nullptr;
155 else
156 break;
157 }
158 }
159
160 ClearModifyFlag();
161
162 return bNextDoc;
163}
164
165/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SfxPrinter * getPrinter(bool bCreate) const =0
Return the printer set at the document.
sal_Int32 m_nOptions
Definition: sdrhhcwrap.hxx:34
void StartTextConversion()
Definition: sdrhhcwrap.cxx:91
const vcl::Font * m_pTargetFont
Definition: sdrhhcwrap.hxx:38
std::unique_ptr< OutlinerView > m_pOutlView
Definition: sdrhhcwrap.hxx:33
LanguageType m_nTargetLang
Definition: sdrhhcwrap.hxx:37
LanguageType m_nSourceLang
Definition: sdrhhcwrap.hxx:36
virtual ~SdrHHCWrapper() override
Definition: sdrhhcwrap.cxx:77
sal_uInt16 m_nDocIndex
Definition: sdrhhcwrap.hxx:35
bool m_bIsInteractive
Definition: sdrhhcwrap.hxx:39
SdrTextObj * m_pTextObj
Definition: sdrhhcwrap.hxx:32
virtual bool ConvertNextDocument() override
Definition: sdrhhcwrap.cxx:96
SdrHHCWrapper(SwView *pVw, LanguageType nSourceLanguage, LanguageType nTargetLanguage, const vcl::Font *pTargetFnt, sal_Int32 nConvOptions, bool bInteractive)
Definition: sdrhhcwrap.cxx:38
SwView * m_pView
Definition: sdrhhcwrap.hxx:31
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
virtual bool SdrBeginTextEdit(SdrObject *pObj, SdrPageView *pPV=nullptr, vcl::Window *pWin=nullptr, bool bIsNewObj=false, SdrOutliner *pGivenOutliner=nullptr, OutlinerView *pGivenOutlinerView=nullptr, bool bDontDeleteOutliner=false, bool bOnlyOneView=false, bool bGrabFocus=true)
SdrPageView * GetSdrPageView() const
virtual const tools::Rectangle & GetLogicRect() const override
weld::Window * GetFrameWeld() const
SwDoc * GetDoc()
returns Doc. But be careful!
Definition: docsh.hxx:204
IDocumentDeviceAccess const & getIDocumentDeviceAccess() const
Definition: doc.cxx:252
static void GetTextObjectsFromFormat(std::list< SdrTextObj * > &, SwDoc &)
get data collection of anchored objects, handled by with contact
Definition: dcontact.cxx:752
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
const IDocumentDeviceAccess & getIDocumentDeviceAccess() const
Provides access to the document device interface.
Definition: viewsh.cxx:2819
void MakeVisible(const SwRect &)
Definition: viewsh.cxx:649
SdrView * GetDrawView()
Definition: vnew.cxx:386
Definition: view.hxx:146
SwWrtShell & GetWrtShell() const
Definition: view.hxx:423
SwEditWin & GetEditWin()
Definition: view.hxx:426
SwDocShell * GetDocShell()
Definition: view.cxx:1193
constexpr Size GetSize() const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
virtual void SetText(const OUString &rStr) override
sal_Int64 n
OutlinerMode