LOK: Implement parts for Writer too.
In Writer, the meaning of 'parts' is a bit different than in Calc or Impress. In Writer, the parts mean pages, and the document does not give a completely different view, the cursor just jumps to the given page. It is up to the client to follow the cursor appropriately to have the desired effect. Change-Id: I56b3264e0340cd639bdabfa92b74b52bd1f391a5
This commit is contained in:
parent
75a84417af
commit
512b782cf4
@ -359,6 +359,13 @@ static void populatePartSelector()
|
||||
lok_doc_view_get_part( LOK_DOC_VIEW(pDocView) ) );
|
||||
}
|
||||
|
||||
static void signalSize(LOKDocView* /*pLOKDocView*/, gpointer /*pData*/)
|
||||
{
|
||||
g_bPartSelectorBroadcast = false;
|
||||
populatePartSelector();
|
||||
g_bPartSelectorBroadcast = true;
|
||||
}
|
||||
|
||||
static void changePart( GtkWidget* pSelector, gpointer /* pItem */ )
|
||||
{
|
||||
int nPart = gtk_combo_box_get_active( GTK_COMBO_BOX(pSelector) );
|
||||
@ -567,6 +574,7 @@ int main( int argc, char* argv[] )
|
||||
g_signal_connect(pDocView, "command-changed", G_CALLBACK(signalCommand), NULL);
|
||||
g_signal_connect(pDocView, "search-not-found", G_CALLBACK(signalSearch), NULL);
|
||||
g_signal_connect(pDocView, "part-changed", G_CALLBACK(signalPart), NULL);
|
||||
g_signal_connect(pDocView, "size-changed", G_CALLBACK(signalSize), NULL);
|
||||
g_signal_connect(pDocView, "hyperlink-clicked", G_CALLBACK(signalHyperlink), NULL);
|
||||
|
||||
|
||||
|
@ -114,6 +114,7 @@ enum
|
||||
COMMAND_CHANGED,
|
||||
SEARCH_NOT_FOUND,
|
||||
PART_CHANGED,
|
||||
SIZE_CHANGED,
|
||||
HYPERLINK_CLICKED,
|
||||
|
||||
LAST_SIGNAL
|
||||
@ -581,6 +582,8 @@ callback (gpointer pData)
|
||||
gtk_widget_set_size_request(GTK_WIDGET(pDocView),
|
||||
twipToPixel(priv->m_nDocumentWidthTwips, priv->m_fZoom),
|
||||
twipToPixel(priv->m_nDocumentHeightTwips, priv->m_fZoom));
|
||||
|
||||
g_signal_emit(pDocView, doc_view_signals[SIZE_CHANGED], 0, NULL);
|
||||
}
|
||||
break;
|
||||
case LOK_CALLBACK_SET_PART:
|
||||
@ -1706,6 +1709,21 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass)
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
|
||||
/**
|
||||
* LOKDocView::size-changed:
|
||||
* @pDocView: the #LOKDocView on which the signal is emitted
|
||||
* @aCommand: NULL, we just notify that want to notify the UI elements that are interested.
|
||||
*/
|
||||
doc_view_signals[SIZE_CHANGED] =
|
||||
g_signal_new("size-changed",
|
||||
G_TYPE_FROM_CLASS(pGObjectClass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
|
||||
/**
|
||||
* LOKDocView::hyperlinked-clicked:
|
||||
* @pDocView: the #LOKDocView on which the signal is emitted
|
||||
|
@ -406,6 +406,14 @@ public:
|
||||
long nTileHeight ) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::getDocumentSize().
|
||||
virtual Size getDocumentSize() SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::setPart().
|
||||
virtual void setPart(int nPart) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::getParts().
|
||||
virtual int getParts() SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::getPart().
|
||||
virtual int getPart() SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::getPartName().
|
||||
virtual OUString getPartName(int nPart) SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::initializeForTiledRendering().
|
||||
virtual void initializeForTiledRendering() SAL_OVERRIDE;
|
||||
/// @see vcl::ITiledRenderable::registerCallback().
|
||||
|
@ -43,6 +43,9 @@ class SwVisCrsr
|
||||
vcl::Cursor m_aTextCrsr;
|
||||
const SwCrsrShell* m_pCrsrShell;
|
||||
|
||||
/// For LibreOfficeKit only - remember what page we were at the last time.
|
||||
sal_uInt16 m_nPageLastTime;
|
||||
|
||||
void _SetPosAndShow();
|
||||
|
||||
public:
|
||||
|
@ -67,6 +67,7 @@ MapMode* SwSelPaintRects::s_pMapMode = 0;
|
||||
// Starting from here: classes / methods for the non-text-cursor
|
||||
SwVisCrsr::SwVisCrsr( const SwCrsrShell * pCShell )
|
||||
: m_pCrsrShell( pCShell )
|
||||
, m_nPageLastTime(0)
|
||||
{
|
||||
pCShell->GetWin()->SetCursor( &m_aTextCrsr );
|
||||
m_bIsVisible = m_aTextCrsr.IsVisible();
|
||||
@ -179,6 +180,17 @@ void SwVisCrsr::_SetPosAndShow()
|
||||
|
||||
if (m_pCrsrShell->isTiledRendering())
|
||||
{
|
||||
// notify about page number change (if that happened)
|
||||
sal_uInt16 nPage, nVirtPage;
|
||||
const_cast<SwCrsrShell*>(m_pCrsrShell)->GetPageNum(nPage, nVirtPage);
|
||||
if (nPage != m_nPageLastTime)
|
||||
{
|
||||
m_nPageLastTime = nPage;
|
||||
OString aPayload = OString::number(nPage - 1);
|
||||
m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
|
||||
}
|
||||
|
||||
// notify about the cursor position & size
|
||||
Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height());
|
||||
OString sRect = aSVRect.toString();
|
||||
m_pCrsrShell->libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
|
||||
|
@ -3152,6 +3152,50 @@ Size SwXTextDocument::getDocumentSize()
|
||||
aDocSize.Height() + 2L * DOCUMENTBORDER);
|
||||
}
|
||||
|
||||
void SwXTextDocument::setPart(int nPart)
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
|
||||
if (!pWrtShell)
|
||||
return;
|
||||
|
||||
pWrtShell->GotoPage(nPart + 1, true);
|
||||
}
|
||||
|
||||
int SwXTextDocument::getParts()
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
|
||||
if (!pWrtShell)
|
||||
return 0;
|
||||
|
||||
return pWrtShell->GetPageCnt();
|
||||
}
|
||||
|
||||
int SwXTextDocument::getPart()
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
|
||||
if (!pWrtShell)
|
||||
return 0;
|
||||
|
||||
sal_uInt16 nPage, nLogPage;
|
||||
OUString sDisplay;
|
||||
pWrtShell->GetPageNumber(-1, pWrtShell->IsCrsrVisible(), nPage, nLogPage, sDisplay);
|
||||
|
||||
return nPage - 1;
|
||||
}
|
||||
|
||||
OUString SwXTextDocument::getPartName(int nPart)
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
||||
return OUString(SW_RES(STR_PAGE)) + OUString::number(nPart + 1);
|
||||
}
|
||||
|
||||
void SwXTextDocument::initializeForTiledRendering()
|
||||
{
|
||||
SolarMutexGuard aGuard;
|
||||
|
Loading…
x
Reference in New Issue
Block a user